<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta>
    <title>管理员登录</title>
    <!--    引入index.css样式表-->
    <link href="/WebContent/HTML/css/adminlogin.css" rel="stylesheet">
    <!--    引入commen.css样式表-->
    <link href="/WebContent/CSS/commend.css" rel="stylesheet">
    <!--    引入reset.css样式表-->
    <link href="/WebContent/CSS/reset.css" rel="stylesheet">
    <!--    引入JQuery-->
    <script src="/WebContent/HTML/js/jquery-3.4.1.js" type="text/javascript"></script>
</head>
<body>
     <header class="header">
        <a href="#" title="北方民族大学论坛管理员登录入口">
            <div class="login">

            </div>
        </a>
        <div class="welcome">
            你好，欢迎来到北方民族大学论坛管理系统
        </div>
     </header>
     <article class="article">
         <div class="list-title">
             管理员登录
         </div>
         <div class="list-cont">
             <div class="list-cade">
                 <form class="adminlogin clear" action="/AdminLoginServlet" method="post" id="form">
                     <input type="hidden" name="type" value="adminlogin">
                     <div class="right">
                         <div class="login-list">
                             <div class="user"></div>
                             <input class="username" type="text" name="username" placeholder="请输入管理员账号">
                         </div>
                         <div class="login-list">
                             <div class="mm"></div>
                             <input class="password" type="password" name="password" placeholder="请输入管理员密码">
                         </div>
                         <div class="login-list" style="display: flex; justify-content: space-around">
                             <span><input type="radio" name="admintype" value="pg" class="rediock" checked>普管</span>
                             <span><input type="radio" name="admintype" value="cg" class="rediock">超管</span>
                         </div>
                         <div class="login-list">
                             <button type="button" id="loginbtn">登录</button>
                             <button type="reset">重置</button>
                         </div>
                         <span class="login-list-wenzi">
                         <a href="UserLogin.jsp" target="_self">我是用户&gt;&gt;</a>
                     </span>
                     </div>
                 </form>
             </div>
         </div>
     </article>
     <script>
         $(document).ready(function () {
             function yanzheng(){
                 var username = $(".username").val();
                 var password = $(".password").val();
                 var admintype = $(".rediock").val();
                 //console.log($("input[name='admintype']:checked").val());
                 if(username == ""){
                     alert("用户名不能为空！");
                 }else if(password == ""){
                     alert("密码不能为空！")
                 }else{
                     var s = $(".adminlogin").serialize();
                     var data = decodeURIComponent(s);    //处理serialize()获取值的中文乱码
                     $.ajax({
                         url:"/SystemGL",
                         async:false,
                         type:"get",
                         data:{
                             "type":"logincheck"
                         },
                         dataType:"text",
                         success:function (x) {
                             if(x == "1"){
                                 $("#form").submit();
                             }else if(x == "0"){
                                 //过滤超级管理员
                                 if($("input[name='admintype']:checked").val() == "cg"){
                                     $("#form").submit();
                                 }else{
                                     alert("系统维护中，暂停服务！");
                                 }
                             }
                         },
                         error:function (error) {
                             alert("请求失败！")
                         }
                     })

                 }
             }
             $("#loginbtn").click(yanzheng);
         })
     </script>
</body>
</html>